package com.starbug.n1;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 *  @Author Starbug
 *  @Date 2021/5/23 15:33
 */
@Slf4j(topic = "c.Test5")
public class Test5 {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (true) {
                boolean interrupted = Thread.currentThread().isInterrupted();
                if (interrupted) {
                    log.debug("被打断,退出循环");
                    break;
                }
            }
        }, "t1");

        t1.start();

        TimeUnit.SECONDS.sleep(1);

        log.debug("interrupt");

        t1.interrupt();

    }

}
